﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DcsGauges.Gui.Gauges.Trigger;
using DcsGauges.Gui.Gauges.Interfaces;

namespace DcsGauges.Gui.Gauges.ValueConverters
{
    class ThreeStateToggleSwitchConverter : IGaugeValueConverter<float, ThreeStateToggleSwitchGauge.SwitchState>
    {
        #region Interface Implemenation
        
        public ThreeStateToggleSwitchGauge.SwitchState Convert(float value)
        {
            if(value < 0)       return ThreeStateToggleSwitchGauge.SwitchState.State0;
            else if (value > 0) return ThreeStateToggleSwitchGauge.SwitchState.State2;
            else                return ThreeStateToggleSwitchGauge.SwitchState.State1;
        }

        public float ConvertBack(ThreeStateToggleSwitchGauge.SwitchState value)
        {
            switch(value)
            {
                case ThreeStateToggleSwitchGauge.SwitchState.State0:            return -1.0f;
                case ThreeStateToggleSwitchGauge.SwitchState.State1:            return  0.0f;
                case ThreeStateToggleSwitchGauge.SwitchState.State2:            return  1.0f;
            }       
            
            return 0.0f;
        }

        #endregion
    }
}
